<template>
  <div>
    <emFrom :model="model" :rules="rules" ref="loginForm">
      <emFromItem label="用户名" prop="username">
        <emInput v-model="model.username"></emInput>
      </emFromItem>
      <emFromItem label="密码" prop="password">
        <emInput v-model="model.password" type="password"></emInput>
      </emFromItem>
      <emFromItem>
        <button  text="登录" @click="onLogin">登录</button>
      </emFromItem>
    </emFrom>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      model: {
        username: "xxxxxx",
        password: "12313214"
      },
      rules: {
        username: [{ required: true, message: "用户名必填" }],
        password: [{ required: true, message: "密码必填" }]
      }
    };
  },

  computed: {},
  watch: {},
  methods: {
      onLogin(){
          this.$refs.loginForm.validate((isvali)=>{
              console.log(isvali)
              if(isvali){
                  alert('登录')
              }{
                  alert('有错')
              }
          })
      }
  }
};
</script>

<style scoped>
</style>
